import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control


// import '../mock' // simulation data

// import uploader from 'vue-simple-uploader'  

import './main.css'
// import { from } from '_rxjs@6.5.1@rxjs';

// Vue.use(uploader)

Vue.use(ElementUI)

Vue.config.productionTip = false


let Modules = [
  require.context('./components/dialog', true, /\.vue$/),
  require.context('./components/filterFrom', true, /\.vue$/),
  require.context('./components/input', true, /\.vue$/),
  require.context('./components/select', true, /\.vue$/),
  require.context('./components/tabel', true, /\.vue$/),
  require.context('./components/tree', true, /\.vue$/),
  require.context('./components/treeTable', true, /\.vue$/),
  require.context('./components/upload', true, /\.vue$/),
  require.context('./components/selectTree', true, /\.vue$/),
]
Modules.forEach(el=>{
  el.keys().forEach(fileName => {
    const componentConfig = el(fileName);
    const componentName = fileName.replace(/^\.\//,'').replace(/\.vue$/,'');
    const component = Vue.component(
        componentName.replace(/\//,'-'),
        componentConfig.default || componentConfig
    )
  })
})

router.beforeEach((to,from,next)=>{
  next()
  // if(to.path == '/login'){
  //   next()
  // }else{
  //   if(window.localStorage.getItem('user')){
  //     next()
  //   }else{
  //     next('/login')
  //   }
  // }
})

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
